package BitCreeekClient;

import BitCreekLib.Host;
import BitCreekLib.IRMIPeer;

import java.rmi.RemoteException;
import java.net.Socket;
import java.io.IOException;


public class PeerServices implements IRMIPeer {
    /**
     * Costruttore di PeerServices
     *
     * @throws RemoteException
     */
    public PeerServices () throws RemoteException {
        super ();
    }

    /* metodo che puo essere richiamato dal servente */
    public void notifyMe ( String torrenetName, Host host ) throws RemoteException {
        boolean find = false;
        for ( Host h : Client.downloads.get ( torrenetName ).swarmInfo.keySet() )  {
            if ( host.equals(h) ) {
                find = true;
                break;
            }
            
        }

        if ( !find )
        		Client.downloads.get( torrenetName ).swarmInfo.put(host, new PeerInfo());

        String returnMessage = "Call back received: " + torrenetName + " From:" + host.toString ();
        Log.add ( returnMessage );
    }
}
